package com.ggh.jinjilive.ui;

import androidx.lifecycle.ViewModel;

import com.ggh.jinjilive.remotedata.systemapi.SystemApiService;

import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;

public class BaseViewModel extends ViewModel {
    public boolean isRefresh;
    public int pageSize = 20;
    public int page = 1;



    public SystemApiService apiCallInterface;
    //管理RxJava，主要针对RxJava异步操作造成的内存泄漏
    private CompositeDisposable mCompositeDisposable;


    public BaseViewModel(SystemApiService apiCallInterface) {
        this.apiCallInterface = apiCallInterface;
        mCompositeDisposable = new CompositeDisposable();
    }


    protected void addSubscribe(Disposable disposable) {
        if (mCompositeDisposable == null) {
            mCompositeDisposable = new CompositeDisposable();
        }
        mCompositeDisposable.add(disposable);
    }
}
